<?php

$auth = Auth::getAuth('current_user');
$db = new Database();
$userCompany = new userQueries();

$formID = $_POST['FormID'];
$requestID = $_POST['RequestID'];

$results = $db->query("SELECT form_table_name FROM tb_workspace WHERE id = {$db->escape($formID)}", 'row');
$tblname = $results['form_table_name'];


$requestDetails = $db->query("SELECT FORM.*, concat_ws(' ',REQUESTOR.first_name,REQUESTOR.last_name) as Requestor_Fullname, REQUESTOR.display_name as Requestor_Name, 
        PROCESSOR.display_name as Processor_Name FROM " . $tblname . " FORM 
        LEFT JOIN tbuser REQUESTOR
        ON REQUESTOR.id = FORM.Requestor
        LEFT JOIN tbuser PROCESSOR
        ON PROCESSOR.id = FORM.Processor
        WHERE FORM.id = {$db->escape($requestID)}");


echo json_encode($requestDetails);
?>